<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01.同步【阻塞】</title>
  </head>

  <body>

  </body>
  <script>
    // ----------------------第一题:变量提升------------

    /* var c = a + b;
    var a = 1;
    var b = 2;
    // 因为a,b会变量提升成undefined,undefined+undefined=NaN
    console.log(c); //NaN */


    // --------------------------第二题:模拟假死----------------------------------
    var a = 1;
    var b = 2;
    var c = a + b;
    var time01 = new Date().getTime();
    var time02 = new Date().getTime();
    var i = 0; //计数
    console.log(time01);
    console.log(time02);
    while (time02 - time01 < 2000) {
      i++;
      console.log(i);
      time02 = new Date().getTime();
    }
    //这段代码在输出结果之前⽹⻚会进⼊⼀个类似假死的状态
    console.log(c); //3
  </script>

</html>